package cm.day09;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Test3 {
    public static void main(String[] args) {
        try {
            read1();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.out.println("==========");
        try {
            read2();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void read1() throws IOException {
        FileInputStream fps=new FileInputStream("D:\\aaa\\file01.txt");
        int read = fps.read();
        System.out.println(read);
    }
    public static void read2() throws IOException {
        FileInputStream fps=new FileInputStream("D:\\aaa\\file01.txt");
        byte[] buf = new byte[3];
        int len = fps.read(buf);
        System.out.println("第1次读取"+len+"个字节数"+new String(buf,0,len));
        len=fps.read(buf);
        System.out.println("第2次读取"+len+"个字节数"+new String(buf,0,len));
        len= fps.read(buf);
        System.out.println("第3次读取"+len+"个字节数"+new String(buf,0,len));
        len = fps.read(buf);
        System.out.println("第4次读取"+len+"个字节数"+new String(buf,0,len));
        len=fps.read(buf);
        System.out.println(len);


    }
}
